home *** CD-ROM | disk | FTP | other *** search
/ Collection of Tools & Utilities / Collection of Tools and Utilities.iso / pascal / thelp4.zip / THELP4.PAS < prev   
Pascal/Delphi Source File  |  1988-03-04  |  39KB  |  841 lines

  1. {$R-}    {Range checking off}
  2. {$B+}    {Boolean complete evaluation on}
  3. {$S+}    {Stack checking on}
  4. {$I+}    {I/O checking on}
  5. {$N-}    {No numeric coprocessor}
  6. {$M 1024,0,3072}
  7.  
  8. { Program THELP was originally written by a Mr. Glenn Wood of the Greenville PC Club of
  9. Greenville, Texas.  This updated version was reprogrammed by John Sloan, AlphaOmega
  10. Computer Services, Devon, Alberta (CIS 71310,2267).  It is entirely memory
  11. resident and takes up about 46,944 K of memory space.  It has been tested on
  12. PCjr, PC CGA, EGA, PS2 VGA, MCGA.  To keep the memory size down, many of the
  13. original Procedure and Function help screens have been deleted.  These, however,
  14. are still available from the Turbo 4.0 editor using either <F1> or <ALT-F1>.
  15. Thelp 4.0 now installs correctly on the PCjr and searches for any available
  16. user interrupt between 60H and 67H.  If it finds an available slot it will
  17. install itself, otherwise it will abort with an error message.  Thelp 4.0
  18. will also detect whether it has already been installed or not.  The window
  19. routines have been borrowed from Eric Snyder's excellent Minigen vs 1.3
  20. screen generator.  This program uses Snyder's MGProg.TPU unit to compile.
  21. }
  22.  
  23.  
  24. PROGRAM THELP;
  25.  
  26. { $C-}
  27.  
  28. {VARIABLE SECTION FOR 'THELP'}
  29.  
  30. Uses
  31.   Crt,
  32.   Dos,
  33.   MGProg;
  34.  
  35. const
  36.   EntryChar       = 35;                { ALT 'H' }
  37.   Escape          = 0;
  38.   FirstRow        = 3;
  39.   FirstCol        = 11;
  40.   WindowWidth     = 60;
  41.   WindowLength    = 18;
  42.   Dr              = 3;
  43.   Mr              = 15;
  44.   Cr              = $0D;
  45.   KybdInt         = $16;
  46.   maxpage         = 5;  {maximum # of pages for each menu item}
  47.   Maxline         = 68;
  48.  
  49. Type
  50.   text80 = string[80];
  51.   Str80  = string[80];
  52.   FldTyp = Record
  53.            Typ             : Char;
  54.            Col,Row,Atr,Len : Byte;
  55.            Txt             : Str80;
  56.            End;
  57.   ScreenArray = Array[1..Maxline] of Fldtyp;
  58.  
  59. var
  60.   UserInt    : byte;
  61.   exitcode   : word;
  62.   reg        : Registers;
  63.   i,j,x,y    : integer;
  64.   Selection  : integer;
  65.   Vector1,
  66.   Vector2    : Pointer;
  67.   pagetop    : array[1..maxpage] of byte;
  68.   page       : byte;
  69.   Esc        : boolean;
  70.  
  71. { MISC. PROCEDURES AND FUNTIONS FOR THELP }
  72. procedure Brite(line:text80);
  73. begin
  74.   textcolor(15);
  75.   write(line);
  76.   textcolor(7);
  77. end;
  78.  
  79. procedure PrintHeading;
  80. begin
  81.   brite('T');       write('URBO Pascal ');
  82.   brite('Help   ');  write('Ver 4.0');
  83. end;
  84.  
  85. { MENU PRINT PROCEDURES FOR THELP }
  86.  
  87. procedure PrintMenu(number:integer);
  88. begin
  89.   case number of
  90.     0  : begin
  91.            gotoxy(mr+4,2);   PrintHeading;
  92.            gotoxy(mr+7,5);  brite('MAIN MENU');
  93.            gotoxy(mr,6);   write('<1> Syntax Structure');
  94.            gotoxy(mr,7);   write('<2> Compiler Directives');
  95.            gotoxy(mr,8);  write('<3> Fatal Runtime Errors');
  96.            gotoxy(mr,9);  write('<4> I/O Errors and Dos Errors');
  97.            gotoxy(mr,10);  write('<5> Reserved Words');
  98.            gotoxy(mr,11); write('<6> Keyboard Scan codes');
  99.          end;
  100.     1  : begin
  101.            gotoxy(mr+4,2);   PrintHeading;
  102.            gotoxy(mr+6,5);   brite('SYNTAX STRUCTURE MENU');
  103.            gotoxy(mr,6);   write('<1> Types and Type Casting');
  104.            gotoxy(mr,7);   write('<2> Constants and Typed Constants');
  105.            gotoxy(mr,8);   write('<3> Variables');
  106.            gotoxy(mr,9);   write('<4> Operators');
  107.            gotoxy(mr,10);  write('<5> Program Structure');
  108.            gotoxy(mr,11);  write('<6> Procedure and Function Structure');
  109.            gotoxy(mr,12);  write('<7> Unit Structure');
  110.            gotoxy(mr,13);  write('<8> Statements');
  111.          end;
  112.   end;{case}
  113.  
  114.   repeat
  115.     gotoxy(14,18);  Brite('Enter Selection or <ESC> to Exit ');
  116.     reg.ax := $00;
  117.     Intr(userint,reg);
  118.     selection:=reg.ah -1
  119.   until ((selection in [0..9]) and (number = 0))
  120.      or ((selection in [0..8]) and (number = 1));
  121.   clrscr;
  122. end;
  123.  
  124. Procedure WriteScreen(Numfields:byte; Var FieldsArray);
  125.  
  126. Type
  127.     ScreenArray = Array[1..Maxline] of Fldtyp;{allows variable length arrays
  128.                                                to be passed in as an untyped
  129.                                                variable and then typecast to
  130.                                                this array type}
  131.  
  132. Var i,j,k:byte;
  133.     key   :char;
  134.  
  135. procedure Pause(var key:char);
  136.  
  137. Var ch:char;
  138.  
  139. begin  Case key of
  140.     '1':begin
  141.         gotoxy(22,18); brite('<PgDn>');write(' for next PAGE');
  142.         Repeat until Keypressed;
  143.         Repeat
  144.           ch:=Readkey;
  145.           if ord(ch) = 00 then
  146.           ch:=readkey;
  147.           if (ord(ch)= 81) or (ord(ch)=51) then key:='D';
  148.         Until ord(ch) in [51,81];
  149.         end;
  150.     'E':begin
  151.          gotoxy(12,18); brite('<PgUp> ');write('for previous page or ');brite('<Esc> for MENU');
  152.          Repeat until Keypressed;
  153.         Repeat
  154.          ch:=Readkey;
  155.          if ord(ch) = 00 then
  156.          ch:=readkey;
  157.          if (ord(ch)= 73) or (ord(ch)=57) then key:='U';
  158.          if (ord(ch)= 01) then key:='E';
  159.         Until ord(ch) in [57,73,$1B];
  160.         end;
  161.  'U','D':begin
  162.         gotoxy(12,18); brite('<PgUp> ');write('for previous page or ');brite('<PgDn>');
  163.           write(' for next PAGE');
  164.         Repeat until Keypressed;
  165.         Repeat
  166.           ch:=Readkey;
  167.           if ord(ch) = 00 then
  168.           ch:=readkey;
  169.           if (ord(ch)= 73) or (ord(ch)=57) then key:='U';
  170.           if (ord(ch)= 81) or (ord(ch)=51) then key:='D';
  171.          Until ord(ch) in [51,57,73,81];
  172.         end;
  173.   end;{case}
  174.  
  175. clrscr;
  176.  
  177. end; {Pause}
  178.  
  179. Begin  {WriteScreen}
  180. pagetop[1]:=1;
  181. I:=1;
  182. page:=1;
  183. Esc:=False;
  184. key:='1';
  185.  
  186. Repeat
  187.    With ScreenArray(FieldsArray)[I] do WinRite(Txt,Col,Row,Atr);
  188.    I:=I+1;
  189.    If (ScreenArray(Fieldsarray)[I].Row =1) or (I = Numfields +1) then
  190.       begin
  191.         If I = Numfields + 1 then key :='E';
  192.         Pause(key);
  193.         case key of
  194.         'U':If page <> 1 then
  195.             begin
  196.               I:=pagetop[page-1];
  197.               page:=page-1;
  198.             If page = 1 then
  199.               key:='1';
  200.             end;
  201.             {else
  202.             begin
  203.               I:=1;
  204.               key:='1';
  205.             end;}
  206.         'D':begin
  207.               page:=page+1;
  208.               pagetop[page]:=I
  209.             end;
  210.         'E':Esc:=True;
  211.        end;{Case}
  212.      end; {if}
  213. Until Esc;
  214.  
  215. end; {WriteScreen}
  216.  
  217. procedure Wait;
  218. begin
  219.   gotoxy(17,18); brite('Press <ESC> To Return to MENU');
  220.   repeat
  221.     reg.ax := 0;
  222.     Intr(userint,reg);
  223.   until reg.ah = $01;
  224.   clrscr;
  225. end;
  226.  
  227. procedure PrintType;
  228.  
  229. Type
  230.   Str80  = string[80];
  231.   FldTyp = Record
  232.            Typ             : Char;
  233.            Col,Row,Atr,Len : Byte;
  234.            Txt             : Str80;
  235.            End;
  236.  
  237. Const
  238.   NumFields   = 28;
  239.   FieldsArray :  Array[1..Numfields] of Fldtyp =
  240.   (
  241.   (Typ:'T';Col:23;Row:1;Atr:31;Len:60;Txt:'TYPES (pg. 207)'),
  242.   (Typ:'T';Col:2;Row:2;Atr:31;Len:60;Txt:'   Simple Type: (pg. 208)'),
  243.   (Typ:'T';Col:2;Row:3;Atr:23;Len:60;Txt:'    days      = 1..30; {Ordinal}'),
  244.   (Typ:'T';Col:2;Row:4;Atr:23;Len:60;Txt:'    day       = (monday,tuesday,wednesday,thursday,'),
  245.   (Typ:'T';Col:2;Row:5;Atr:23;Len:60;Txt:'                friday,saturday,sunday); {Enumerated}'),
  246.   (Typ:'T';Col:2;Row:6;Atr:23;Len:60;Txt:'    letter    = ''a''..''z''); {subrange}'),
  247.   (Typ:'T';Col:2;Row:7;Atr:23;Len:60;Txt:'    Hex       = byte; {0..255}'),
  248.   (Typ:'T';Col:2;Row:8;Atr:23;Len:60;Txt:'    Smallnum  = shortint; {-128..127}'),
  249.   (Typ:'T';Col:2;Row:9;Atr:23;Len:60;Txt:'    A/D_range = integer; {-32768..32767}'),
  250.   (Typ:'T';Col:2;Row:10;Atr:23;Len:60;Txt:'    Address   = word; {0..65535}'),
  251.   (Typ:'T';Col:2;Row:11;Atr:31;Len:60;Txt:'   Boolean Type: (pg. 210)'),
  252.   (Typ:'T';Col:2;Row:12;Atr:23;Len:60;Txt:'    Switch    = boolean {False < True}'),
  253.   (Typ:'T';Col:2;Row:13;Atr:31;Len:60;Txt:'   Char type: (pg. 210)'),
  254.   (Typ:'T';Col:2;Row:14;Atr:23;Len:60;Txt:'    C         = char {''A''..''Z'',''a''..''z'',''0''..''9''}'),
  255.   (Typ:'T';Col:23;Row:1;Atr:31;Len:60;Txt:'TYPES (con''t)'),
  256.   (Typ:'T';Col:2;Row:2;Atr:31;Len:60;Txt:'   Real type